package a_obsolete;
import junit.framework.TestCase;
import javax.swing.*;

/**
 * JUnit to test the createUser method in AddEditUser
 * @author bethanysumner
 *
 */
public class AddEditUserTest extends TestCase {
	
	/**
	 * Run the boolean addNewAdmin(String,String,String,String,String) method test.
	 *
	 * @throws Exception
	 *
	 */
	public void testCreateUser() throws Exception{
		
		// LoginPanel has been updated, so this JUnit test needs to be updated to run
		// I commented everything out so we wouldn't get errors -- Bethany
		  
		/* 
		
		AddEditUser aeu = new AddEditUser(-1);
		
		
		// all the fields are blank, so we should get every single error message
		aeu.createUser();
		assertEquals("Username should be 4 - 24 characters long. " +
				"Please enter the first name. Please enter the last name. " +
				"The phone number should consist of 10 digits. " +
				"Please enter the email address. " +
				"Please indicate the sex. " +
				"Please select the day of the birth day. " +
				"Please select the month of the birth day. " +
				"Please select the year of the birth day. ", 
				aeu.getLblMessage().getText());
		
		
		aeu.getTxtFirstName().setText("bethany");
		aeu.getTxtLastName().setText("sumner");
		aeu.getTxtUserName().setText("username");
		aeu.getTxtPhone().setText("7704761572");
		aeu.getTxtEmail().setText("bsumner8@gatech.edu");
		aeu.getComboMonth().setSelectedIndex(1);
		aeu.getComboDay().setSelectedIndex(1);
		aeu.getComboYear().setSelectedIndex(1);
		aeu.getRdbtnFemale().setSelected(true);
		aeu.getRdbtnMale().setSelected(false);
		
		// all the fields are valid, so the error message should be empty
		aeu.createUser();
		assertEquals("", aeu.getLblMessage().getText());
		
		
		// testing when the username is too short
		aeu.getTxtUserName().setText("tu");
		aeu.createUser();
		assertEquals("Username should be 4 - 24 characters long. ", aeu.getLblMessage().getText());
		
		aeu.getTxtUserName().setText("username"); //reset
		
		// testing when the username is too long
		aeu.getTxtUserName().setText("abcdefghijklmnopqrstuvwxyz");
		aeu.createUser();
		assertEquals("Username should be 4 - 24 characters long. ", aeu.getLblMessage().getText());
		
		aeu.getTxtUserName().setText("username"); //reset
		
		// testing when the phone number is too short
		aeu.getTxtPhone().setText("45768");
		aeu.createUser();
		assertEquals("The phone number should consist of 10 digits. ", aeu.getLblMessage().getText());
		
		aeu.getTxtPhone().setText("7704761572"); //reset
		
		// testing when the phone number is too long
		aeu.getTxtPhone().setText("770-476-1572");
		aeu.createUser();
		assertEquals("The phone number should consist of 10 digits. ", aeu.getLblMessage().getText());
		
		aeu.getTxtPhone().setText("7704761572"); //reset
		
		// testing when there are letters in the phone number
		aeu.getTxtPhone().setText("770476PULL");
		aeu.createUser();
		assertEquals("The phone number should only contain numbers. ", aeu.getLblMessage().getText());
		
		aeu.getTxtPhone().setText("7704761572"); //reset

		*/
		
	}

}
